package org.example;


public class Main35 {
    public static void main(String[] args) {
        System.out.println("测试1");
        String str = "abcba";
        if(isPalindrome(str))
            System.out.println(str + "是回文");
        else
            System.out.println(str + "不是回文");
        str = "1221";
        if(isPalindrome(str))
            System.out.println(str + "是回文");
        else
            System.out.println(str + "不是回文");
    }


    public static boolean isPalindrome(String str) {
        SqStackClass<Character> st = new SqStackClass();
        int n = str.length();
        char i =0;
        while (i < n/2) {
            st.push(str.charAt(i));
            i++;
        }
        if(n%2==1)
            i++;
        while (i<n){
            if(st.pop()!=str.charAt(i))
                return false;
            i++;
        }
            return true;

    }
}